using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace AzureusWrapper
{
    public class Download
    {
        public Stats DownloadStats;
        public Torrent TorrentInformation;
        public ScrapeResult ScrapeResult;
        public AnnounceResult AnnounceResult;
        public int Position;

        public string ObjectId;

        public Download(XmlNode serializedDownload)
        {
			XmlNode torrent = serializedDownload;//.ChildNodes[0];
            XmlNode stats = serializedDownload;//.ChildNodes[1];
			XmlNode announce = serializedDownload;//.ChildNodes[2];
            XmlNode scrape = serializedDownload;//.ChildNodes[3];

            this.Position = Int32.Parse(((XmlElement)serializedDownload).GetElementsByTagName("position")[0].InnerText.Trim());
            this.DownloadStats = new Stats(stats);
            this.TorrentInformation = new Torrent(torrent);
            this.AnnounceResult = new AnnounceResult(announce);
            this.ScrapeResult = new ScrapeResult(scrape);

            this.ObjectId = serializedDownload.LastChild.InnerText.Trim();
        }
    }
}
